package com.allwees.bs.c.module.user.entity;

import com.allwees.bs.c.common.auth.constant.EAuthType;
import com.allwees.bs.c.module.app.AppDeviceInfo;
import com.allwees.bs.core.model.user.entity.UserModel;
import com.allwees.bs.core.modelbase.constant.ResultCode;
import com.allwees.bs.core.modelbase.exception.BusinessException;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Table;

@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "usr_user")
public class UserEntity extends UserModel implements AppDeviceInfo {
	private static final long serialVersionUID = 8636996042860366884L;

	/**
	 * 获取第三方认证类型对应id
	 *
	 * @param type
	 *            第三方认证类型
	 * @return id
	 */
	public String getIdByAuthType(EAuthType type) {
		switch(type) {
			case FACEBOOK:
				return getFacebookId();
			case GOOGLE:
			case MOCK_GOOGLE:
				return getGoogleId();
			case APPLE:
				return getAppleId();
//			case TWITTER:
//				return getTwitterId();
			default:
				throw new BusinessException(ResultCode.UNKNOWN_AUTH_TYPE,"Unknown auth type");
		}

	}
}
